/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsf.beans.admin;

import com.sun.faces.facelets.tag.jsf.core.LoadBundleHandler;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import manager.ReligionManager;
import model.admin.Religion;

/**
 *
 * @author Danh
 */
@ManagedBean
@RequestScoped
public class ReligionBean {

    private int religionId;
    private String religionName;
    private boolean religionStatus;

    public ReligionBean(int religionId, String religionName, boolean religionStatus) {
        this.religionId = religionId;
        this.religionName = religionName;
        this.religionStatus = religionStatus;
    }

    public int getReligionId() {
        return religionId;
    }

    public void setReligionId(int religionId) {
        this.religionId = religionId;
    }

    public String getReligionName() {
        return religionName;
    }

    public void setReligionName(String religionName) {
        this.religionName = religionName;
    }

    public boolean isReligionStatus() {
        return religionStatus;
    }

    public void setReligionStatus(boolean religionStatus) {
        this.religionStatus = religionStatus;
    }

    public ReligionBean() {
    }

    public void reset() {
        religionName = "";
        religionStatus = false;
    }
public String editAction(int id, String name, boolean status) {
        this.religionId = id;
        this.religionName = name;
        this.religionStatus= status;
        return "updateReligion.xhtml";
    }

    public List<Religion> getReligion() {
        List<Religion> list;
        ReligionManager mana = new ReligionManager();
        list = mana.getReligon();
        return list;
    }

    public void insertReligion() {
        Religion c = new Religion(this.religionName, this.religionStatus);
        ReligionManager mana = new ReligionManager();
        boolean result = mana.insertReligon(c);
        if (result) {
            getReligion();
        }
    }
       public String deleteReligion(int id) {
        ReligionManager mana = new ReligionManager();
        boolean deleteCountry = mana.deleteReligion(id);
        if (deleteCountry) {
            return "Religion.xhtml?faces-redirect=true";
        }
        return "";
    }
    public String sua()
    {
     Religion pr = new Religion(this.religionId, this.religionName, this.religionStatus);
       ReligionManager mana=new ReligionManager();
        mana.update(pr);
        return "Religion.xhtml?faces-redirect=true";
        
    }
}
